﻿// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information.
// Website: https://admin.blazor.zone

using BlazorAdmin.Models;
using Microsoft.Extensions.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;

namespace BlazorAdmin.Web.Shared.Services
{
    /// <summary>
    /// AppContext 实体类
    /// </summary>
    public class BootstrapAppContext
    {
        /// <summary>
        /// JWT密钥
        /// </summary>
        public const string JWT_SecurityKey = "19C4198379954597B74CC5677B64CAE6";
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="configuration"></param>
        public BootstrapAppContext(IConfiguration configuration)
        {
            AppID = configuration.GetValue("AppID", "BA")!;
        }

        /// <summary>
        /// 获得/设置 当前网站 AppId
        /// </summary>
        public string AppID { get; }

        /// <summary>
        /// 获得/设置 当前登录账号
        /// </summary>
        [NotNull]
        public string? LoginName { get; set; }

        /// <summary>
        /// 获得/设置 当前登录账号
        /// </summary>
        [NotNull]
        public string? LoginPassword { get; set; }

        /// <summary>
        /// 获得/设置 当前登录的域
        /// </summary>
        [NotNull]
        public string? LoginDomain { get; set; }
        /// <summary>
        /// 获得/设置 是否记住当前登录用户名和密码
        /// </summary>
        public bool IsRemember { get; set; }
        /// <summary>
        /// 获得/设置 当前登录用户名和密码是否为域登录
        /// </summary>
        public bool IsDomain { get; set; } = false;

        /// <summary>
        /// 获得/设置 应用程序基础地址 如 http://localhost:5210
        /// </summary>
        [NotNull]
        public Uri? BaseUri { get; set; }
        /// <summary>
        /// 票证
        /// </summary>
        public ClaimsPrincipal? ClaimsPrincipal { get; set; }
        /// <summary>
        /// Jwt中的用户数据
        /// </summary>
        public JwtUserData? UserData { get; set; }
        /// <summary>
        /// 当前登录用户
        /// </summary>
        public User? CurrentUser { get; set; }
    }
}
